<template>
  <view class="meeting-item">
    <view>
      <view class="meeting-hd flex-row-sb-c">
        <text>{{ index < 10 ? `${0}${index + 1} ` : index+1 }} {{ data.teamDeptName }}</text>
        <text v-if="data.finishFlag === 1">{{ data.score === 0 || data.score ? `会议评分：${data.score}分` : '' }}</text>
        <text v-else>{{ data.meetingNodeType | meetingNodeName }}</text>
      </view>
      <view class="meeting-row">
        <text>会议编号:</text><text>{{ data.meetingCode | empty }}</text>
      </view>
      <view class="meeting-row">
        <text>会议时间:</text><text>{{ meetingTime(data.meetingTime) | empty }}</text>
      </view>
      <view class="meeting-row">
        <text>所属部门:</text><text>{{ data.parentDeptName | empty }}</text>
      </view>
      <view class="meeting-row">
        <text>班次:</text><text>{{ data.className | empty }}</text>
      </view>
      <view class="meeting-row">
        <text>当班班长:</text><text>{{ data.monitorName | empty }}</text>
      </view>
    </view>
    <view class="meeting-bottom">
      <view class="meeting-bottom-btn-group flex flex-auto justify-end">
        <view class="meeting-btn meeting-btn-active" @click="handlenNavigate">查看</view>
        <view class="meeting-btn" v-if="isCurrentMeeting && data.procTaskId" @click="handlenNavigate(2)">
          {{ data.meetingNodeType | buttonValue }}
        </view>
      </view>
    </view>
  </view>
</template>
<script>
import dayjs from 'dayjs'
const urlMap = {
  5: 'meeting-handle/comprehensive',
  2: 'meeting-handle/index',
  3: 'meeting-handle/index',
  4: 'meeting-handle/index',
  9: 'meeting-handle/record',
  10: 'meeting-handle/speak',
  7: 'meeting-handle/score',
  8: 'meeting-handle/index',
}
const nodeNameMap = {
  5: '综合主办汇报',
  2: '生产主办汇报',
  3: '设备主办汇报',
  4: '安全主办汇报',
  9: '记录',
  10: '讲话',
  7: '评分',
  8: '班长确认'
}
const buttonValueMap = {
  5: '汇报',
  2: '汇报',
  3: '汇报',
  4: '汇报',
  9: '记录',
  10: '领导讲话',
  7: '评分',
  8: '确认'
}
export default {
  props: {
    data: {
      type: Object,
      default: () => ({}),
    },
    index: {
      type: Number,
      default: 0
    },
    type: {
      type: Number,
      default: 1,
    },
  },
  methods: {
    // 1 查看  2处理
    handlenNavigate(type = 1) {
      let url = 'meeting-record/index'
      if (type === 2) {
        url = urlMap[this.data.meetingNodeType]
      }

      uni.navigateTo({
        url: `/pages/work/team-or-group/${url}?id=${this.data.meetingId}&meetingNodeType=${this.data.meetingNodeType}&procTaskId=${this.data.procTaskId}&type=${this.type}`,
      })
    },
  },
  filters: {
    empty(val) {
      return val || '--'
    },
    meetingNodeName(nodeType) {
      return nodeType ? nodeNameMap[nodeType] : ''
    },
    buttonValue(nodeType) {
      return nodeType ? buttonValueMap[nodeType] : ''
    }
  },
  computed: {
    isCurrentMeeting() {
      return this.type === 1
    },
    meetingTime() {
      return function (time) {
        return time ? dayjs(time).format('YYYY/MM/DD HH:mm') : time
      }
    },
  },
}
</script>
<style lang="scss" scoped>
.meeting-item {
  width: 690rpx;
  height: 502rpx;
  background: #ffffff;
  border-radius: 20rpx 20rpx 20rpx 20rpx;
  opacity: 1;
  margin: 0 auto;
  padding: 30rpx 30rpx 20rpx 30rpx;
  font-size: 28rpx;
  font-family: PingFang SC-Regular, PingFang SC;
  font-weight: 400;
}

.meeting-item > view > view {
  display: flex;
  align-items: center;
}

.meeting-hd {
  font-weight: bold;
  font-size: 34rpx;
  font-family: PingFang SC-Bold, PingFang SC;
  color: #333333;
  height: 52rpx;
  margin-bottom: 20rpx;
  @include text-overflow-ellipsis(1);

  image {
    width: 52rpx;
    height: 52rpx;
    margin-right: 18rpx;
  }
}

.meeting-row {
  color: #999999;
  margin-bottom: 20rpx;

  text {
    display: inline-block;
  }

  text:first-child {
    width: 140rpx;
    text-align: right;
    margin-right: 12rpx;
  }

  text:last-child {
    color: #333333;
    flex: 1;
    @include text-overflow-ellipsis(1);
  }
}

.meeting-bottom {
  border-top: 1rpx solid #d5d7e3;
  display: flex;
  align-items: center;
  padding-top: 20rpx;
  justify-content: space-between;

  .meeting-row {
    margin-bottom: 0;
  }

  .meeting-btn {
    width: 140rpx;
    height: 60rpx;
    border-radius: 32rpx 32rpx 32rpx 32rpx;
    opacity: 1;
    border: 1rpx solid #c87c32;
    font-size: 28rpx;
    color: #c87c32;
    text-align: center;
    line-height: 60rpx;
    margin-left: 20rpx;
  }

  .meeting-btn-active {
    color: #454a5e;
    border-color: #454a5e;
    margin-left: 0;
  }
}

.meeting-item .meeting-row-active {
  color: #88b4c4 !important;
}

.meeting-bottom-btn-group {
  display: flex;
  align-items: center;
}
</style>
